home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6424 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.iadfw.net!usenet
  2. From: Larry Weiss <lfw@iadfw.net>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: [Perf:] mem*() procs vs. array looping
  5. Date: Sat, 24 Feb 1996 14:12:46 -0600
  6. Organization: ---
  7. Message-ID: <312F713E.57E7@iadfw.net>
  8. References: <4glkq1$gu7@gazette.tandem.com>
  9. NNTP-Posting-Host: dal09-01.ppp.iadfw.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14.  
  15. Francis E. Chang wrote:
  16. > Are mem*() procedures performance boosters?  For example, for using
  17. >   memcpy(tgt, src, length);
  18. > instead
  19. >   for (index=0; index < length; index++)
  20. >     tgt[i] = src[i];
  21.  
  22.  
  23. Issues of relative execution time of equivalent coded expressions are
  24. in the realm of "quality of implementation".   There are no absolute
  25. answers for all implementations.   One can discover by purely emperical
  26. evidence, or by evidence of inspection of the "machine language"
  27. generated by the compiler which expressions work better given a specific
  28. implementation, and then try to generalize to the most common finding,
  29. or embed conditional compilation (#if/#else/#endif) into your C code
  30. to emit the best for each implementation.   
  31.  
  32. A new version of a compiler (or choice of a selectable optimization
  33. strategy with the same compiler) may change the behaviour with
  34. respect to optimal code emitted.   
  35.  
  36. In any case, it's a fair assumption that the library's implementation is
  37. efficient, and should not be avoided on run-time performance grounds.
  38. With the new Standard, the compiler is allowed to generate inline machine 
  39. instructions if it wants to to avoid the overhead of the function call 
  40. for Standard library function calls.
  41.